package io;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;

public class OOSDemo {
    public static void main(String[] args) throws IOException {
        String name = "狗子";
        int age = 5;
        String gender = "女";
        String[] oherInfo = {"喜欢吃汉堡","喜欢喝可乐"};
        Person p = new Person(name,age,gender,oherInfo);
        System.out.println(p);
        //将person对象写入文件person.obj中
        FileOutputStream fos = new FileOutputStream("person.obj");
        ObjectOutputStream oos = new ObjectOutputStream(fos);
        oos.writeObject(p);
        System.out.println("写出完毕");
        oos.close();

    }
}
